Skip to content

Conversation

@Zoxc
Copy link
Contributor

@Zoxc Zoxc commented Mar 6, 2024

This encodes dep graph edges directly from the previous graph when promoting nodes from a previous session, avoiding allocations / copies.

Based on #122064 and #116375.

BenchmarkBeforeAfter
TimeTime%
🟣 clap:check:unchanged0.4177s0.4072s💚 -2.52%
🟣 hyper:check:unchanged0.1430s0.1420s -0.69%
🟣 regex:check:unchanged0.3106s0.3038s💚 -2.19%
🟣 syn:check:unchanged0.5823s0.5688s💚 -2.33%
🟣 syntex_syntax:check:unchanged1.3992s1.3692s💚 -2.14%
Total2.8528s2.7910s💚 -2.17%
Summary1.0000s0.9803s💚 -1.97%

@rustbot
Copy link
Collaborator

rustbot commented Mar 6, 2024

r? @fmease

rustbot has assigned @fmease.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 6, 2024
@Zoxc
Copy link
Contributor Author

Zoxc commented Mar 6, 2024

r? @cjgillot

@rustbot rustbot assigned cjgillot and unassigned fmease Mar 6, 2024
@rust-log-analyzer

This comment has been minimized.

@Zoxc Zoxc force-pushed the dep-edges-from-previous branch from de02827 to 34a3025 Compare March 6, 2024 08:06
@rust-log-analyzer

This comment has been minimized.

@cjgillot
Copy link
Contributor

cjgillot commented Mar 8, 2024

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Mar 8, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 8, 2024
Encode dep graph edges directly from the previous graph when promoting

This encodes dep graph edges directly from the previous graph when promoting nodes from a previous session, avoiding allocations / copies.

Based on rust-lang#122064 and rust-lang#116375.

<table><tr><td rowspan="2">Benchmark</td><td colspan="1"><b>Before</b></th><td colspan="2"><b>After</b></th></tr><tr><td align="right">Time</td><td align="right">Time</td><td align="right">%</th></tr><tr><td>🟣 <b>clap</b>:check:unchanged</td><td align="right">0.4177s</td><td align="right">0.4072s</td><td align="right">💚  -2.52%</td></tr><tr><td>🟣 <b>hyper</b>:check:unchanged</td><td align="right">0.1430s</td><td align="right">0.1420s</td><td align="right"> -0.69%</td></tr><tr><td>🟣 <b>regex</b>:check:unchanged</td><td align="right">0.3106s</td><td align="right">0.3038s</td><td align="right">💚  -2.19%</td></tr><tr><td>🟣 <b>syn</b>:check:unchanged</td><td align="right">0.5823s</td><td align="right">0.5688s</td><td align="right">💚  -2.33%</td></tr><tr><td>🟣 <b>syntex_syntax</b>:check:unchanged</td><td align="right">1.3992s</td><td align="right">1.3692s</td><td align="right">💚  -2.14%</td></tr><tr><td>Total</td><td align="right">2.8528s</td><td align="right">2.7910s</td><td align="right">💚  -2.17%</td></tr><tr><td>Summary</td><td align="right">1.0000s</td><td align="right">0.9803s</td><td align="right">💚  -1.97%</td></tr></table>
@bors
Copy link
Collaborator

bors commented Mar 8, 2024

⌛ Trying commit d9fe043 with merge ae110c4...

@bors
Copy link
Collaborator

bors commented Mar 9, 2024

☀️ Try build successful - checks-actions
Build commit: ae110c4 (ae110c4e0298a288fd51f34ac53ca2e19f205e2f)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (ae110c4): comparison URL.

Overall result: ❌✅ regressions and improvements - ACTION NEEDED

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.6% [0.2%, 1.2%] 25
Regressions ❌
(secondary)
0.8% [0.7%, 0.9%] 4
Improvements ✅
(primary)
-0.7% [-1.8%, -0.2%] 32
Improvements ✅
(secondary)
-1.1% [-2.8%, -0.2%] 22
All ❌✅ (primary) -0.2% [-1.8%, 1.2%] 57

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
3.3% [0.9%, 6.1%] 4
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.2% [-4.0%, -1.9%] 6
All ❌✅ (primary) - - 0

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.7% [2.3%, 3.4%] 3
Improvements ✅
(primary)
-2.4% [-7.0%, -1.4%] 53
Improvements ✅
(secondary)
-3.0% [-6.1%, -1.2%] 20
All ❌✅ (primary) -2.4% [-7.0%, -1.4%] 53

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 649.968s -> 649.736s (-0.04%)
Artifact size: 172.54 MiB -> 172.56 MiB (0.01%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Mar 9, 2024
@Zoxc Zoxc force-pushed the dep-edges-from-previous branch from d9fe043 to bb9f99c Compare March 10, 2024 08:53
Copy link
Contributor

@cjgillot cjgillot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you provide an explanation where the gains come from? I suspected we remove the need to decode the edges, but that's not it.

self.record_edge(
dep_node_index,
prev_graph.index_to_node(prev_index),
prev_graph.fingerprint_by_index(prev_index),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we keep the let-bindings for those two? They are computed by promote IIUC.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to keep them close to their use in promote.

if let Some(record_graph) = &mut record_graph.try_lock() {
record_graph.push(index, node.node, &node.edges);
}
let edges = edges(self);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move this call inside the closure?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted the closure construction to be able to be optimized out.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Could you add a comment to justify the outline?

node: DepNode,
fingerprint: Fingerprint,
prev_index: SerializedDepNodeIndex,
prev_index_to_index: &mut IndexVec<SerializedDepNodeIndex, Option<DepNodeIndex>>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why &mut?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about uniqueness, but it doesn't help here. I've changed it to &.

@cjgillot cjgillot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 10, 2024
let edges = prev_graph
.edge_targets_from(prev_index)
.map(|i| prev_index_to_index[i].unwrap())
.collect();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR avoids this copy and allocation into EdgesVec.

@Zoxc Zoxc force-pushed the dep-edges-from-previous branch from bb9f99c to 4704852 Compare March 11, 2024 02:28
@Zoxc
Copy link
Contributor Author

Zoxc commented Mar 13, 2024

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 13, 2024
@cjgillot
Copy link
Contributor

@bors r+

@bors
Copy link
Collaborator

bors commented Mar 23, 2024

📌 Commit 4704852 has been approved by cjgillot

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 23, 2024
}

#[inline]
fn encode_promoted<D: Deps>(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a comment on this method, to explain the difference with encode?

let stat = stats.entry(kind).or_insert(Stat { kind, node_counter: 0, edge_counter: 0 });
stat.node_counter += 1;
stat.edge_counter += edge_count as u64;
outline(move || {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a comment to justify the outline?

if let Some(record_graph) = &mut record_graph.try_lock() {
record_graph.push(index, node.node, &node.edges);
}
let edges = edges(self);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Could you add a comment to justify the outline?

}

#[inline]
fn promote_node(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you document this method? and the difference with encode_node?

@cjgillot
Copy link
Contributor

@bors r-

Actually, could you add a few comments there and there?
r=me afterwards

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Mar 23, 2024
@Zoxc Zoxc force-pushed the dep-edges-from-previous branch from 4704852 to aa9c9a3 Compare March 23, 2024 19:24
@Zoxc
Copy link
Contributor Author

Zoxc commented Apr 5, 2024

@oli-obk Do you mind approving for me?

@oli-obk
Copy link
Contributor

oli-obk commented Apr 5, 2024

@bors r=cjgillot

@bors
Copy link
Collaborator

bors commented Apr 5, 2024

📌 Commit aa9c9a3 has been approved by cjgillot

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 5, 2024
@bors
Copy link
Collaborator

bors commented Apr 5, 2024

⌛ Testing commit aa9c9a3 with merge 4563f70...

@bors
Copy link
Collaborator

bors commented Apr 5, 2024

☀️ Test successful - checks-actions
Approved by: cjgillot
Pushing 4563f70 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Apr 5, 2024
@bors bors merged commit 4563f70 into rust-lang:master Apr 5, 2024
@rustbot rustbot added this to the 1.79.0 milestone Apr 5, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (4563f70): comparison URL.

Overall result: ❌✅ regressions and improvements - ACTION NEEDED

Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please open an issue or create a new PR that fixes the regressions, add a comment linking to the newly created issue or PR, and then add the perf-regression-triaged label to this PR.

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.4% [0.4%, 0.4%] 1
Improvements ✅
(primary)
-1.6% [-3.1%, -0.2%] 113
Improvements ✅
(secondary)
-1.5% [-3.6%, -0.3%] 37
All ❌✅ (primary) -1.6% [-3.1%, -0.2%] 113

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
4.1% [4.1%, 4.1%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.9% [-7.8%, -0.8%] 99
Improvements ✅
(secondary)
-3.3% [-7.3%, -1.5%] 27
All ❌✅ (primary) -2.9% [-7.8%, -0.8%] 99

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 668.072s -> 669.208s (0.17%)
Artifact size: 317.99 MiB -> 318.05 MiB (0.02%)

@rustbot rustbot added the perf-regression Performance regression. label Apr 5, 2024
@Kobzol
Copy link
Member

Kobzol commented Apr 5, 2024

The improvements obviously overweigh the single regression.

@rustbot label: +perf-regression-triaged

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-query-system Area: The rustc query system (https://rustc-dev-guide.rust-lang.org/query.html) merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. perf-regression-triaged The performance regression has been triaged. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants